import os

src_dir = "/home/chenl/workspace/chenldesign"
src_suffix = ['.cpp', '.h', 'c']

dest_file = "/home/chenl/workspace/chenldesign/src.txt"

df = file(dest_file, 'w+') 

for root, dirs, files in os.walk(src_dir):
	print "files = ",  files
	for src_file in files:
		print "src_file = ", src_file
		for item in src_suffix:
			print "item = ", item
			if src_file.find(item) != -1:
				print '*' + src_file, root 
				sf = file(root+'/'+src_file, 'r')
				df.write("/******************************\n")
				df.write("* file_name: " + src_file + '\n')
				df.write("*******************************/\n\n")
				while True:
  					line = sf.readline()
    					if len(line) == 0: # Zero length indicates EOF
        					break
					print 'line = ', line
					df.write(line)
				df.write("\n\n")
				sf.close()
				break;

df.close()
		
